package com.hongning.railway.ui.main.fragments.college;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.hongning.railway.R;
import com.hongning.railway.databinding.FragmentCollegeExamBinding;
import com.hongning.railway.ui.adapter.BaseFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.Arrays;

import me.goldze.mvvmhabit.BR;
import me.goldze.mvvmhabit.base.BaseFragment;

/**
 * Author: zhangjing
 * DATA:2019-08-10 15:10
 * DESC:
 * email:zhangjingworkmol@163.com
 */
public class CollegeExamFrament extends BaseFragment<FragmentCollegeExamBinding,CollegeExamViewModel> {
    public static CollegeExamFrament newInstance() {

        Bundle args = new Bundle();

        CollegeExamFrament fragment = new CollegeExamFrament();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_college_exam;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        initViewPager();
    }

    private void initViewPager() {
        ArrayList<Fragment> fragments=new ArrayList<>();
        String[] title={"未完成","已完成"};
        fragments.add(ExamUnCompleteFragment.newInstance());
        fragments.add(ExamCompleteFragment.newInstance());
        BaseFragmentPagerAdapter pagerAdapter = new BaseFragmentPagerAdapter(getChildFragmentManager(), fragments, Arrays.asList(title));
        binding.vpContent.setAdapter(pagerAdapter);
        binding.stlExam.setViewPager(binding.vpContent,title);
    }
}
